package com.renchunlin.myview

import android.animation.ObjectAnimator
import android.animation.ValueAnimator
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.animation.DecelerateInterpolator
import com.renchunlin.qqstepview.QQStepView

class MainActivity : AppCompatActivity() {

    private lateinit var stepView: QQStepView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        stepView = findViewById(R.id.stepView)
        stepView.setStepMax(4000)

        //属性动画 后面讲的内容
        initAnimation()
    }

    private fun initAnimation() {
        val valueAnimator: ValueAnimator = ObjectAnimator.ofFloat(0f, 3000f)
        //设置动画持续时间
        valueAnimator.duration = 3000
        //设置插值器-动画渐变-快-慢
        valueAnimator.interpolator = DecelerateInterpolator()
        valueAnimator.addUpdateListener { animation ->
            val animatedValue: Float = animation.animatedValue as Float
            stepView.setCurrentStep(animatedValue.toInt())
        }
        valueAnimator.start()
    }
}